Conversation
Co-authored-by: maitamgk <169973104+maitamgk@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA new application-wide logger utility is introduced in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
2 issues found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/utils/logger.ts">
<violation number="1" location="src/utils/logger.ts:12">
P2: `isDev` falls back to `true`, which can unintentionally enable debug logs outside development when env metadata is unavailable.</violation>
<violation number="2" location="src/utils/logger.ts:18">
P2: Falsy payload values are silently dropped because `data` is checked with truthiness instead of `undefined` presence.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| }; | ||
|
|
||
| class Logger { | ||
| private isDev = import.meta.env?.DEV ?? true; |
There was a problem hiding this comment.
P2: isDev falls back to true, which can unintentionally enable debug logs outside development when env metadata is unavailable.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/utils/logger.ts, line 12:
<comment>`isDev` falls back to `true`, which can unintentionally enable debug logs outside development when env metadata is unavailable.</comment>
<file context>
@@ -0,0 +1,28 @@
+};
+
+class Logger {
+ private isDev = import.meta.env?.DEV ?? true;
+
+ private log(level: LogLevel, message: string, data?: unknown): void {
</file context>
| private isDev = import.meta.env?.DEV ?? true; | |
| private isDev = import.meta.env?.DEV ?? false; |
| if (!this.isDev && level === 'debug') return; | ||
| const timestamp = new Date().toISOString().slice(11, 23); | ||
| const prefix = '[' + timestamp + '] [' + level.toUpperCase() + ']'; | ||
| if (data) { console.log('%c' + prefix + ' ' + message, LOG_COLORS[level], data); } |
There was a problem hiding this comment.
P2: Falsy payload values are silently dropped because data is checked with truthiness instead of undefined presence.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/utils/logger.ts, line 18:
<comment>Falsy payload values are silently dropped because `data` is checked with truthiness instead of `undefined` presence.</comment>
<file context>
@@ -0,0 +1,28 @@
+ if (!this.isDev && level === 'debug') return;
+ const timestamp = new Date().toISOString().slice(11, 23);
+ const prefix = '[' + timestamp + '] [' + level.toUpperCase() + ']';
+ if (data) { console.log('%c' + prefix + ' ' + message, LOG_COLORS[level], data); }
+ else { console.log('%c' + prefix + ' ' + message, LOG_COLORS[level]); }
+ }
</file context>
Colored console logger with log levels for development.
Summary by cubic
Adds a lightweight logger with color-coded console output and four levels (debug, info, warn, error). It standardizes logs and hides debug messages outside development.
Written for commit 7813004. Summary will update on new commits.
Summary by CodeRabbit